﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReDiscussDAL : SyncBase<Model.ReDiscuss>
    {
        static ReDiscussDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReDiscussDAL.addSQL = @"insert into TempReDiscuss(TeacherID, LessionID, DiscussID, StartTime, StartPiont, StudentID, EndTime, EndPiont) values 
                                                        (@TeacherID,@LessionID,@DiscussID,@StartTime,@StartPiont,@StudentID,@EndTime,@EndPiont)";
            ReDiscussDAL.tbName = "TempReDiscuss";
            ReDiscussDAL.remoteUrl = "/Ayyfford/AddReDiscuss";
            ReDiscussDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7}),",
                                          t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.DiscussID.NullNumber(), t.StartTime.NullDate(), t.StartPiont.NullNumber(), t.StudentID.NullNumber(), t.EndTime.NullDate(), t.EndPiont.NullNumber());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReDiscuss t)
        {
            SyncBase<Model.ReDiscuss>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReDiscuss>.AsyncData();
        }
    }
}
